package bomberman;

import java.io.Serializable;
import java.util.Hashtable;

/**
 *
 * @author eirikb
 */
public class Game implements Serializable {

    private String name;
    private Hashtable<String, User> users;
    private int max;
    private boolean showNicks;
    private int width;
    private int height;

    public Game(String name, int max, boolean showNicks,
            int width, int height) {
        this.name = name;
        this.max = max;
        this.showNicks = showNicks;
        this.width = width;
        this.height = height;
        users = new Hashtable<String, User>();
    }

    public void addUser(User user) {
        users.put(user.getNick(), user);
    }

    public void removeUser(User user) {
        users.remove(user.getNick());
    }

    public String getName() {
        return name;
    }

    public Hashtable<String, User> getUsers() {
        return users;
    }

   // public void setReady(String nick, boolean ready) {
   //     users.put(nick, Boolean.valueOf(ready));
   // }

   // public boolean getReady(String) {
    //    return users.get(nick).booleanValue();
   // }

    public int getMax() {
        return max;
    }

    public int getReady() {
        int tot = 0;
        for (User user : users.values()) {
            if (user.isReady()) {
                tot++;
            }
        }
        return tot;
    }

    public int getHeight() {
        return height;
    }

    public int getWidth() {
        return width;
    }

    @Override
    public String toString() {
        return "[" + users.size() + "/" + max + "] " + name;
    }
}
